package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ReleaseStatus;
import jdk.jshell.Snippet;
import org.simpleframework.xml.convert.Convert;
import org.springframework.core.convert.converter.Converter;

import java.lang.annotation.Annotation;

public class StringToReleaseStatusConverter implements Converter<String,ReleaseStatus> {

    @Override
    public ReleaseStatus convert(String source) {
        ReleaseStatus[] values = ReleaseStatus.values();
        for (ReleaseStatus value : values) {
            if (value.getCode() == Integer.parseInt(source)){
                return value;
            }
        }
        throw new RuntimeException("非法参数异常,仅支持0,1");
    }
}
